home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
pxewin.zip
/
PXEOBJ.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-10
|
6KB
|
194 lines
// PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
// PXEOBJ.HPP //
// Contents ----------------------------------------------------------------
//
// This header contains the PXEngObject class which is the base class
// for all Paradox related objects. All Engine type objects are derived
// from this base class. The Engine objects are broken down into the
// following class:
//
// 1. PXI. PDOX initialization class.
//
// 2. PXFamily. PDOX family functionality (i.e. Copy, Delete).
//
// 3. PXTbl. PDOX table type functions.
//
// 4. PXRec. PDOX record type functions.
//
// 5. PXField. PDOX base class for all related field subclasses.
//
// 6. PXDIS. For displaying databases.
//
// The necessary interface for inheriting Object and TStreamable is
// also provided. You don't need the OWL to take advantage of these
// classes listed above. You can use them for any type of interface
// you wish to construct.
//
// End ---------------------------------------------------------------------
// External Reference Name for this Header ---------------------------------
#ifndef PXEOBJ_HPP
#define PXEOBJ_HPP
// End ---------------------------------------------------------------------
// Interface Dependencies --------------------------------------------------
#ifndef PXENGINE_H
#include <pxengine.h>
#endif // PXENGINE_H //
#ifndef __OBJSTRM_H
#include <objstrm.h>
#endif // __OBJSTRM_H //
#ifndef PXDEF_HPP
#include "pxdef.hpp"
#endif // PXDEF_HPP //
#ifndef __MATH_H
#include <math.h>
#endif __MATH_H
// End Interface Dependencies ----------------------------------------------
// class PXEngObject //
#define pxengObj 1000 /* This is the Paradox engine object
ID */
_CLASSDEF(PXEngObject)
class PXEngObject:public TStreamable,public Object
{
public:
// The following data structure keeps track of where an error occured
// and what handler to call to return the error string
typedef struct EngError
{
int Origin; /* Where did the error come from.
Is it an engine error or a PXEWIN
error? */
/* Engine error member handler.
This will return the correct
error string depending on the
origin of the error. */
char *(PXEngObject::* _FAR EngMem)(void);
int pxerr; /* Error code */
}EngError;
private:
/* The following member is required
for TStreamable compatible class
functionality. When the stream
manager loads this object on the
stream, it uses this string to
identify the objects type. */
virtual const Pchar streamableName() const
{
return "PXEngObject";
}
protected:
// The following data structure is used to keep track of essentual
// Engine related data between engine class types. A pointer is
// passed to each of the object types: table, record of fields so
// these objects can share this data.
typedef struct EngData
{
Pchar name; /* Name of the data base */
PPXEngObject PXEObjPtr; /* PX engine object pointer. This
allows other objects to reference
a parent object */
EngError Errors; /* Engine error pointer */
TABLEHANDLE tblHandle; /* The table handle */
int num_fields; /* Number of fields in table */
RECORDNUMBER num_recs; /* Number of record in table */
}EngData;
typedef EngData _FAR *PEngData; /* For DLL compatible pointer */
int close_status; /* Status of closure. If set to
OPENED, then the destructor must
call for proper closure. If set
to CLOSED, then the destructor
must not call for closure. */
virtual Pvoid read(Ripstream); /* Read persistant object */
virtual void write(Ropstream); /* Write persistant object */
PXEngObject(StreamableInit) /* Persistant object constructor */
{
}
public:
PEngData EngDataPtr; /* Engine object data pointer */
PRECORDHANDLE recHandle; /* Record handle */
PXEngObject(); /* Initialize error status */
static PTStreamable build(); /* Build persistant object */
virtual Pchar RetPXMsg() /* Return Engine error string */
{
return PXErrMsg(EngDataPtr->Errors.pxerr);
}
/* Return PXEWIN error message */
virtual Pchar RetPXEWINErrorMsg()
{
return EWinMsg[EngDataPtr->Errors.pxerr];
}
virtual classType isA() const
{
return pxengObj;
}
virtual Pchar nameOf() const
{
return "PXEngObject";
}
virtual hashValueType hashValue() const
{
return hashValueType(NULL);
}
virtual int isEqual( const Object&) const
{
return 1;
}
virtual void printOn( ostream _FAR & ) const
{
}
int RetPXError() /* Returns paradox error
code */
{
return EngDataPtr->Errors.pxerr;
}
virtual void PXError(int org); /* Virtual error handler */
virtual Pchar RetPXErrorMsg()
{
return (this->*EngDataPtr->Errors.EngMem)();
}
};
// Description -------------------------------------------------------------
//
// This class provides the necessary interface to TStreamable and Object
// classes. All pure virtuals are define here for now. The engine
// error codes are saved here also as well as the parent object pointer
//
// End ---------------------------------------------------------------------
// Define inserters and extractors for persistant objects:
inline Ripstream operator >> (Ripstream is,RPXEngObject cl)
{return is >> (RTStreamable)cl;}
inline Ripstream operator >> (Ripstream is,RPPXEngObject cl)
{return is >> (RPvoid)cl;}
inline Ropstream operator << (Ropstream os,RPXEngObject cl)
{return os << (RTStreamable)cl;}
inline Ropstream operator << (Ropstream os,PPXEngObject cl)
{return os << (PTStreamable)cl;}
#endif // PXEOBJ_HPP //